home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group93b.txt / 000088_icon-group-sender _Fri May 14 11:12:38 1993.msg < prev    next >
Internet Message Format  |  1993-06-16  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 14 May 1993 12:27:10 MST
  2. Via: uk.ac.manchester.computer-science; Fri, 14 May 1993 18:13:22 +0100
  3. From: Steve Holden <steve@dtc.co.uk>
  4. Date: Fri, 14 May 93 18:03:46 BST
  5. Message-Id: <12646.9305141703@desktop.desktop.co.uk>
  6. To: sboisen@bbn.com
  7. Subject: Re: string stripping
  8. Cc: icon-group@cs.arizona.edu
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. Sean:
  13.  
  14. The conventional way of stripping out unwanted characters woould, I
  15. think, use string scanning.  The basis is to use "upto()" to skip
  16. any you don't want to avoid, and many() to skip the rest.  The code
  17. would look something like this:
  18.  
  19. procedure main()
  20.  
  21. full := "abc-def.ghi"
  22. bare := ""
  23. badchars := '-.'
  24.  
  25. full ? {
  26.     while bare ||:= tab(many(~badchars)) do
  27.         tab(many(badchars))
  28. }
  29. write(bare)
  30.  
  31. end
  32.  
  33. You may notice that despite my suggestion of using "upto()"
  34. I actually used tab(many(~badchars)).  This allows you to include
  35. any trailing good characters as a part of the loop processing
  36. rather than having to program in possible special cases.
  37.  
  38. This group being what it is you may well get several other good
  39. (possibly even better :-) ideas on how to go about this.
  40.  
  41. regards
  42.  Steve
  43.  +---------------------------------+-------------------------------------+
  44.  | Steve Holden, Technical Director| Desktop Connection Limited          |
  45.  | steve@desktop.co.uk             | Manchester Science Park             |
  46.  |---------------------------------+ Lloyd Street North                  |
  47.  | Publish and be damned. Publish  | Manchester England M15 4EN          |
  48.  | electronically and be heard.    | Tel: +44 61 227 9055 Fax: 226 4922  |
  49.  +---------------------------------+-------------------------------------+
  50.